/*******************************************************************************
 * Package: com.hngtrust.iir.company.controller
 * Type:    DictController
 * Date:    2020-11-30 10:59
 *
 * Copyright (c) 2020 HUANENG GUICHENG TRUST CORP.,LTD All Rights Reserved.
 *
 * You may not use this file except in compliance with the License.
 *******************************************************************************/
package com.hngtrust.iir.company.controller;

import com.hngtrust.framework.bind.ResponseInfo;
import com.hngtrust.iir.company.controller.vo.InfoHolderRespVO;
import com.hngtrust.iir.company.controller.vo.InfoPledgeRespVO;
import com.hngtrust.iir.company.controller.vo.InfoSubCompRespVO;
import com.hngtrust.iir.company.controller.vo.ListBankCreditRespVO;
import com.hngtrust.iir.company.controller.vo.ListHolderReqVO;
import com.hngtrust.iir.company.service.CompReportService;
import com.hngtrust.iir.exception.IirErrorType;
import com.hngtrust.iir.exception.IirException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 研报生成的相关接口
 * @author Chentianyong
 * @date 2021-05-28 10:59
 */
@Slf4j
@Api(tags = "研报生成的相关接口")
@RestController
@RequestMapping("/company/report")
public class CompReportController {
    
    @Autowired
    private CompReportService reportService;
    
    
    /**
     * 控股股东信息
     */
    @ApiOperation(value = "控股股东信息", notes = "控股股东信息")
    @PostMapping("/info-holder")
    public ResponseInfo<InfoHolderRespVO> infoHolder(
            @ApiParam(value = "公司参数") @Valid @RequestBody ListHolderReqVO req) {
        log.info("ManageController.infoHolder start...");

        if(!(req.getCompId() > 0L)){
            throw new IirException(IirErrorType.INTFACE_PARAMS_ERROR,"ID");
        }

        InfoHolderRespVO resp = reportService.infoHolder(req);

        ResponseInfo<InfoHolderRespVO> data = new ResponseInfo<>();
        data.setData(resp);
        return data;
    }
    
    /**
     * 股权质押信息
     */
    @ApiOperation(value = "股权质押信息", notes = "股权质押信息")
    @PostMapping("/info-pledge")
    public ResponseInfo<InfoPledgeRespVO> infoPledge(
            @ApiParam(value = "公司参数") @Valid @RequestBody ListHolderReqVO req) {
        log.info("ManageController.infoPledge start...");
        
        if(!(req.getCompId() > 0L)){
            throw new IirException(IirErrorType.INTFACE_PARAMS_ERROR,"ID");
        }
        
        InfoPledgeRespVO resp = reportService.infoPledge(req);
        
        ResponseInfo<InfoPledgeRespVO> data = new ResponseInfo<>();
        data.setData(resp);
        return data;
    }
    
    /**
     * 子公司信息
     */
    @ApiOperation(value = "子公司信息", notes = "子公司信息")
    @PostMapping("/info-sub-comp")
    public ResponseInfo<InfoSubCompRespVO> infoSubComp(
            @ApiParam(value = "公司参数") @Valid @RequestBody ListHolderReqVO req) {
        log.info("ManageController.infoSubComp start...");
        
        if(!(req.getCompId() > 0L)){
            throw new IirException(IirErrorType.INTFACE_PARAMS_ERROR,"ID");
        }
    
        InfoSubCompRespVO resp = reportService.infoSubComp(req);
        
        ResponseInfo<InfoSubCompRespVO> data = new ResponseInfo<>();
        data.setData(resp);
        return data;
    }
    
    /**
     * 公司银行授信列表
     */
    @ApiOperation(value = "公司银行授信列表", notes = "公司银行授信列表")
    @PostMapping("/list-bank-credit")
    public ResponseInfo<List<ListBankCreditRespVO>> listBankCredit(
            @ApiParam(value = "公司参数") @Valid @RequestBody ListHolderReqVO req) {
        log.info("ManageController.listBankCredit start...");
        
        if(!(req.getCompId() > 0L)){
            throw new IirException(IirErrorType.INTFACE_PARAMS_ERROR,"ID");
        }
    
        List<ListBankCreditRespVO> resp = reportService.listBankCredit(req);
        
        ResponseInfo<List<ListBankCreditRespVO>> data = new ResponseInfo<>();
        data.setData(resp);
        return data;
    }
}
